package com.xuchang.model;

import com.xuchang.domain.SysMenu;
import com.xuchang.domain.SysPrivilege;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Collections;
import java.util.List;

@Data
public class SysMenuPrivilegesDto extends SysMenu {
    @ApiModelProperty("该菜单下的所有的权限")
    private List<SysPrivilege> privileges = Collections.emptyList();
    @ApiModelProperty("该菜单的子菜单")
    private List<SysMenuPrivilegesDto> childMenus = Collections.emptyList();
    @ApiModelProperty("该菜单的唯一Key值")
    private  String menuKey;
    /**
     * 获取菜单的唯一Key凭证
     * @return
     */
    public String getMenuKey(){
        if (!StringUtils.isEmpty(getParentKey())) {
            return getParentKey()+"."+getId();
        }else {
            return getId().toString();
        }
    }

}
